<?php
/*
 * Created on 08/07/2009
 *	Authors: Zamna Team ( Correa Delval, Manuel			)
 *						( Jose Garcia, Adan. 			)
 *						( Mendoza Noriega, Francisco.	)
 *						( Noriega Carrasco, Evert. 		)
 *						( Ponce Angulo, Viridiana.		)
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 	include("Answer.php");
 	class Question{
 		private $data;
		private $rank;
		private $weigth;
		private $type;
		private $statement;
		
		private $answers=Array() ;
		private $orderAnswers = Array();
		
		function __construct($_data,$_type,$_statement,$_weigth,$_rank){
			$this -> data=$_data; 
			$this -> type=$_type;
			$this -> statement=$_statement;
			$this -> weigth=$_weigth;
			$this -> rank=$_rank;			
		}
		
		
		//Respuestas
		function addAnswer($answer){
			
			return array_push($this -> answers,$answer);
		}
		
		function getAnswer($indice){
			if( $indice < numberOfAnswers() )
			return $indice;
		}
		
		function numberOfAnswers(){
			return count ($this -> answers);
		}
		
		function initializeAnswers(){
			for($i=0;$i<count ($this -> answers);$i++)
				array_push($this -> orderAnswers,$i);
		}		
		
		function  nextAnswer()
		{
			$indice = rand(0,count($this -> orderAnswers)-1);
			$retorno =  $this -> answers[$this -> orderAnswers[$indice]];
			$this -> answers[$this -> orderAnswers[$indice]]=$this -> answers[$this -> orderAnswers[count($this -> orderAnswers)-1]];
			array_pop($this -> orderAnswers);
			return $retorno;
		}
		
		///pesos
		function getWeigth(){
			return $this ->weigth;
		}
		
		function setWeigth($_weigth){
			$this ->weigth=$_weigth;			
		}
		
		///tipos
		function getAttrType(){
			return $this ->type;
		}
		
		function setAttrType($_type){
			$this ->type=$_type;			
		}
				
		///Estatutos
		function getStatement(){
			return $this ->statement;
		}
		
		function setStatement($_statement){
			$this ->statement=$_statement;
		}
				
		//Rank
		function getRank(){
 			return $this ->rank;
 		}
 		
		function setRank($_rank){
 			 $this ->rank = $_rank;	 
 		}
 		
 		//pregunta
 		function getData(){
 			return $this ->data;
 		}
	}
?>
